﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace NotifyCenter.Projects;

internal class NotificationRuleConfiguration : IEntityTypeConfiguration<NotificationRule>
{
    public void Configure(EntityTypeBuilder<NotificationRule> builder)
    {
        builder.Configure();

        builder.Property(nr => nr.Name)
            .IsRequired()
            .HasMaxLength(255);

        builder.Property(nr => nr.Description).HasMaxLength(2000);

        builder.Property(nr => nr.Type)
            .IsRequired();

        builder.Property(nr => nr.ConfigurationJson).IsRequired()
            .HasMaxLength(2000);

        builder.Property(nr => nr.EnableWebhook);

        builder.Property(nr => nr.WebhookUrl)
            .HasMaxLength(1024);

        builder.Property(nr => nr.WebhookSecret)
            .HasMaxLength(255);

        builder.Property(nr => nr.MaxRetryTimes);
    }
} 
